package mobi.greenplate.client.connect;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpDelete;

/**
 *
 * @author dmakariev
 */
class DeleteTemplate extends DefaultTemplate {

    public DeleteTemplate(HttpClientTemplateContext context) {
        super(context);
    }

    public int execute(HttpClient httpClient) throws Exception {
        final HttpDelete httpDelete = new HttpDelete(getContext().getUrl());
        httpDelete.setParams(getContext().getParams());

        final HttpResponse response = httpClient.execute(httpDelete);

        return handleResponse(response, getContext().getResponseHandler());
    }
}
